


# 28. 实现 strStr()

def main(haystack,needle):
    if needle == '':
        return 0
    if haystack.find(needle) == -1:
        return -1
    for i in range(0, len(haystack)):
        if len(haystack) - i + 1 < len(needle):
            return -1
        for j in range(0, len(needle)):
            if haystack[i] == needle[j]:
                i = i + 1

                if j == len(needle) - 1:
                    return i - len(needle)

                if i >= len(haystack):
                    break
            else:
                break

if __name__ == "__main__":
    haystack = input()
    needle = input()
    result = main(haystack,needle)
    print(result)
    #"mississippi"
    #"sad"